package org.myh.excel.example.singlethread;

import org.apache.poi.ss.usermodel.Row;
import org.myh.excel.SimpleSingleThreadExcelBuffer;
import org.myh.excel.concurrent.AbstractDivisibleExcelBuffer;

import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * ClassName: SingleThreadRead
 * Description:
 * date: 2024/3/26 13:55
 *
 * @author Yu Han
 * @since JDK 1.8
 */
public class SingleThreadRead {


    public void demo() throws Exception {
        Path path = Paths.get("C:\\Users\\Administrator\\Desktop", "宿舍信息上传模板.xlsx");
        InputStream inputStream2 = Files.newInputStream(path);
        SimpleSingleThreadExcelBuffer singleThreadExcelBuffer = new SimpleSingleThreadExcelBuffer(inputStream2, 2048, 500, 0);
        singleThreadExcelBuffer.setCallBack(new AbstractDivisibleExcelBuffer.ExcelDataCallBack<Row>() {
            @Override
            public void sendRowData(int index, Row rowData,int total,boolean hasNext) {
                System.out.println("接收到row数据"+rowData.toString());
            }
        });
        singleThreadExcelBuffer.readExcel();
        System.out.println("执行完毕");
    }

    public static void main(String[] args) throws Exception {
        SingleThreadRead singleThreadRead = new SingleThreadRead();
        singleThreadRead.demo();
    }
}
